//
//  LYMineSegement.m
//  artist
//
//  Created by Jay_Apple on 16/3/1.
//  Copyright © 2016年 viviyoo. All rights reserved.
//

#import "LYMineSegement.h"

@interface LYMineSegement ()
//右边按钮
@property (weak, nonatomic) IBOutlet UIButton *rightBtn;
//左边按钮
@property (weak, nonatomic) IBOutlet UIButton *leftBtn;

//选中按钮
@property (weak, nonatomic) UIButton *selectedBtn;


@end

@implementation LYMineSegement

- (IBAction)btnOnclick:(UIButton *)sender {
    
    if (sender == self.selectedBtn){
        
        return;
    }else{
        
        self.selectedBtn.selected = NO;
        sender.selected = YES;
        self.selectedBtn = sender;
        SegementType type = sender.tag;
        if (self.block) {
            self.block(type);
        }
    }
    
}

- (void)selectType:(SegementType)type{

    switch (type) {
        case SegementTypeFriend:
            [self btnOnclick:self.leftBtn];
            break;
        case SegementTypeArtist:
            [self btnOnclick:self.rightBtn];
    }

}


@end
